package com.lagou.edu.service.impl;

import com.lagou.edu.dao.ArticleRepository;
import com.lagou.edu.pojo.Article;
import com.lagou.edu.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @ClassName: ArticleServiceImpl
 * @Auther: Jerry
 * @Date: 2020/7/22 15:38
 * @Desctiption: TODO
 * @Version: 1.0
 */
@Service
@Transactional
public class ArticleServiceImpl implements ArticleService {

    @Autowired
    private ArticleRepository articleRepository;

    @Override
    public List<Article> findAll() {
        return articleRepository.findAll();
    }

    @Override
    public Page<Article> findPage(Integer pageNo, Integer pageSize) {
        return articleRepository.findAll(PageRequest.of(pageNo, pageSize));
    }
}
